package com.example.myprojectoffeixue;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by ASUS on 2016/9/9.
 */
public class Spinneradapter extends BaseAdapter {

    //spinner适配器

    private ArrayList<String> s;
    private Context con;
    public LinearLayout le;

    public Spinneradapter(ArrayList<String> s, Context con) {
        this.con = con;
        this.s = s;
    }

    @Override
    public int getCount() {
        return s.size();
    }

    @Override
    public Object getItem(int position) {
        return s.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(con, R.layout.item_spinner, null);
        TextView tv = (TextView) convertView.findViewById(R.id.tv_spinner);
        tv.setText(s.get(position));
        return convertView;
    }


}
